﻿@model BookModel
@{
    ViewData["Title"] = "Add New Book";
}

<div class="container">
    <h3 class="display-4">Add New Book</h3>
    <hr/>
    @if (ViewBag.IsSuccess == true)
    {
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            <strong>Holy guacamole!</strong>You should added new book successfully.<br/>
            Click <a asp-controller="Book" asp-action="GetBook" asp-route-id="@ViewBag.BookId">here</a> to view the details.
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
        </div>
    }

    <div class="d-flex justify-content-center">
        <div class="spinner-border" role="status" id="myLoader" style="display: none">
            <span class="sr-only">Loading...</span>
        </div>
    </div>

    <form method="post" enctype="multipart/form-data" data-ajax-="true" data-ajax-complete="myComplete" asp-action="AddNewBook" asp-controller="Book">
        <div asp-validation-summary="ModelOnly" class="text-danger"></div>

        @* <div class="form-group"> *@
        @*     <label asp-for="Language" class="control-label"></label> *@
        @*     <select asp-for="Language" class="form-control"> *@
        @*         <option value="">Please choose book language</option> *@
        @*         <option value="Hindi">Hindi(One of the best language)</option> *@
        @*         <option value="English">English(Global language)</option> *@
        @*         <option value="Dutch">Dutch(My custom message)</option> *@
        @*     </select> *@
        @*     <span asp-validation-for="Language" class="text-danger"></span> *@
        @* </div> *@


        <div class="form-group">
            <label asp-for="LanguageId" class="control-label"></label>
            <select asp-for="LanguageId" class="form-control" asp-items="ViewBag.Language">
                <option value="">Please choose book language</option>
            </select>
            <span asp-validation-for="LanguageId" class="text-danger"></span>
        </div>

        <div class="form-group">
            <label asp-for="Title"></label>
            <input asp-for="Title" class="form-control"/>
            <span asp-validation-for="Title" class="text-danger"></span>
        </div>

        <div class="form-group">
            <label asp-for="Author"></label>
            <input asp-for="Author" class="form-control"/>
            <span asp-validation-for="Author" class="text-danger"></span>
        </div>
        <div class="form-group">
            <label asp-for="Description"></label>
            <textarea asp-for="Description" class="form-control"></textarea>
        </div>
        <div class="form-group">
            <label asp-for="TotalPages"></label>
            <input type="number" asp-for="TotalPages" class="form-control"/>
            <span asp-validation-for="TotalPages" class="text-danger"></span>
        </div>

        <div class="form-group">
            <label asp-for="CoverPhoto"></label>
            <div class="custom-file">
                <input asp-for="CoverPhoto" class="custom-file-input" id="customFile"/>
                <label class="custom-file-label" for="customFile">Chose File</label>
            </div>
            <span asp-validation-for="CoverPhoto" class="text-danger"></span>
        </div>

        <div class="form-group">
            <label asp-for="GalleryFiles"></label>
            <div class="custom-file">
                <input asp-for="GalleryFiles" class="custom-file-input" id="customFile"/>
                <label class="custom-file-label" for="customFile">Chose File</label>
            </div>
            <span asp-validation-for="GalleryFiles" class="text-danger"></span>
        </div>

        <div class="form-group">
            <label asp-for="BookPdf"></label>
            <div class="custom-file">
                <input asp-for="BookPdf" class="custom-file-input" id="customFile"/>
                <label class="custom-file-label" for="customFile">Chose File</label>
            </div>
            <span asp-validation-for="BookPdf" class="text-danger"></span>
        </div>
        
        <div class="form-group">
            <input type="submit" value="Add Book" class="btn btn-primary"/>
        </div>
    </form>
</div>

@section Scripts
{
    <script>
        function myComplete(){
            alert("I am from complete");
        }
    </script>
}